function createApp(rootComponent) {
  return {
    mount(selector) {      
      const container = document.querySelector(selector)
      // 形成闭包
      let isMounted = false
      let oldVNode = null
      // 每次更新调用这个函数
      watchEffect(function () {
        if (!isMounted) {
          oldVNode=rootComponent.render()
          mount(oldVNode,container)
          isMounted=true
        } else {
          const newVNode=rootComponent.render()
          patch(oldVNode,newVNode)
          oldVNode=newVNode
        }
      })
    }
  }
}